package RabbitMQDemos.RabbitMQProducer;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class Producer3 {
    public static void main(String[] args) {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setHost("localhost");
        try {
            Connection connection = factory.newConnection();
            Channel channel = connection.createChannel();
            String exchangeName = "test-exchange";
            channel.exchangeDeclare(exchangeName, "topic");
            String routingKey = "orange.usa";
            byte[] message = "quit".getBytes();
            channel.basicPublish(exchangeName, routingKey, null, message);
            System.out.println(" [x] Sent '" + routingKey + "':'" + message + "'");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
